﻿using Ext.Net;
using NOAH.CMS.Repository;

using System;
using System.Collections.Generic;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;

public partial class admin_Modules_Videos_Default : System.Web.UI.Page
{
    [DirectMethod]
    public void DeleteImage(int id)
    {
        try
        {
            using (FilmRepository repository = new FilmRepository())
            {
                repository.Delete(id);
                repository.SubmitChanges();
                Util.ShowMessage(Constants.UPDATE_SUCCESS);
                this.PagingToolBar2.SetPageIndex(1);
            }
        }
        catch
        {
            Util.ShowMessage(Constants.UPDATE_FAILURE);
        }
    }

    public void DeleteImage(object sender, DirectEventArgs e)
    {
        try
        {
            using (FilmRepository repository = new FilmRepository())
            {
                List<Film> ads = new List<Film>();
                CheckboxSelectionModel selectionModel = (CheckboxSelectionModel)this.GridPanel1.SelectionModel.Primary;
                foreach (SelectedRow row in selectionModel.SelectedRows)
                {
                    repository.Delete(int.Parse(row.RecordID));
                }
                repository.SubmitChanges();
                this.PagingToolBar2.PageIndex = 1;
                Util.ShowMessage(Constants.UPDATE_SUCCESS);
            }
        }
        catch
        {
            Util.ShowMessage2(Constants.UPDATE_FAILURE);
        }
    }

    public void DeleteImageCategories(object sender, DirectEventArgs e)
    {
        try
        {
            using (FilmCategoryRepository repository = new FilmCategoryRepository())
            {
                List<FilmCategory> ads = new List<FilmCategory>();
                CheckboxSelectionModel selectionModel = (CheckboxSelectionModel)this.gridViewImageCategories.SelectionModel.Primary;
                foreach (SelectedRow row in selectionModel.SelectedRows)
                {
                    repository.Delete(int.Parse(row.RecordID));
                }
                repository.SubmitChanges();
                this.PagingToolBar1.PageIndex = 1;
                this.PagingToolBar2.PageIndex = 1;
                Util.ShowMessage(Constants.UPDATE_SUCCESS);
            }
        }
        catch
        {
            Util.ShowMessage2(Constants.UPDATE_FAILURE);
        }
    }

    [DirectMethod]
    public void DeleteImageCategory(int id)
    {
        try
        {
            using (FilmCategoryRepository repository = new FilmCategoryRepository())
            {
                repository.Delete(id);
                repository.SubmitChanges();
                Util.ShowMessage(Constants.UPDATE_SUCCESS);
                this.PagingToolBar1.SetPageIndex(1);
            }
        }
        catch
        {
            Util.ShowMessage(Constants.UPDATE_FAILURE);
        }
    }

    [DirectMethod]
    public string GetImageCategoryTitle(string id)
    {
        return string.Empty;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }

}